package com.example.runner;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/* ━━━━━━佛祖保佑━━━━━━
 *                  ,;,,;
 *                ,;;'(    社
 *      __      ,;;' ' \   会
 *   /'  '\'~~'~' \ /'\.)  主
 * ,;(      )    /  |.     义
 *,;' \    /-.,,(   ) \    码
 *     ) /       ) / )|    农
 *     ||        ||  \)
 *     (_\       (_\
 * ━━━━━━永无BUG━━━━━━
 * @author ：zjq
 * @date ：2020/12/17 10:23
 * @description: TODO    https://www.jianshu.com/p/369a54201943
 *                       BeanPostProcessor前置处理-->检查是否是InitializingBean 以决定是否调用 afterPropertiesSet ---->检查是否配置有自定义的init-method
 *                       -----> BeanPostProcessor后置处理
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 */
@Component
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        // 打印的太多了 ，先注释掉
        /*System.out.println("------------------------------------------------------------------");
        System.out.println("postProcessBeforeInitialization..." + beanName + "=>" + bean);*/
        return bean;
    }

    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException{
       /* System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
        System.out.println("postProcessAfterInitialization..." + beanName + "=>" + bean);*/
        return bean;
    }
}
